layui.use(['table','form', 'element'], function() {
    var form = layui.form
        , $ = layui.$;

    let user = JSON.parse(sessionStorage.getItem("user"));
    let info = '暂无数据';
    if(user){
        $('#username').text(user.username ? user.username : info);
        $('#realName').text(user.realName ? user.realName : info);
        $('#papers').text(user.idNumber ? user.idNumber : info);
        $('#phone').text(user.phone ? user.phone : info);
        $('#email').text(user.email ? user.email : info);
        $('#teaNo').text(user.teaNo ? user.teaNo : info);
        if(user.head){
            $('#head').attr('src', user.head);
        }
    }
    //用户信息修改
    $('#edit').click(() => {

        layer.open({
            type:2,
            title:'基础信息修改',
            area: ['35%','75%'],
            content:'../templates/add/userAdd.html'
        });
    })
    $('#phone').click(() =>{
        sessionStorage.setItem('editType', 0);
        layer.open({
            type:2,
            title:'更换绑定手机号',
            area: ['30%','40%'],
            content:'../templates/add/infoEdit.html'
        });
    })
    $('#email').click(() =>{
        sessionStorage.setItem('editType', 1);
        layer.open({
            type:2,
            title:'修改或添加邮箱',
            area: ['30%','40%'],
            content:'../templates/add/infoEdit.html'
        });
    })
    //获取最新公告
    $.ajax({
        type: 'post',
        url: '/Class/notice/getTop',
        dataType: 'json',
        success: (res) =>{
            if(res.code === 0){
                let d = res.data; //填充数据
                for(let i = 0; i < d.length; i++){
                    $('#timeline>li:nth-child('+ parseInt(i+1) +')>div>h3').text(d[i].title); //标题
                    $('#timeline>li:nth-child('+ parseInt(i+1) +')>div>div').html(d[i].info); //内容
                    $('#timeline>li:nth-child('+ parseInt(i+1) +')>div>span').text(util.getTime(d[i].time)); //时间
                }
            }else layer.msg('系统繁忙');
        }
    })
});
//跳转公告页
function goNotice(e){
    //获取父页面iframe
    let ifr = window.parent.document.getElementById('ifr');
    let url = '../templates/noticeInfo.html';
    ifr.src = url;
}